package com.think.admin.oauth.exception;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;

/**
 * <p>
 * 自定义 OAuth2 异常
 * </p>
 *
 * @author: xwj
 * @data: 2019-05-07
 */
@JsonSerialize(using = CustomOauth2ExceptionSerializer.class)
public class CustomOauth2Exception extends OAuth2Exception {
    private int httpErrorCode;
    private String oAuth2ErrorCode;

    public CustomOauth2Exception(String msg) {
        super(msg);
    }

    public CustomOauth2Exception(String msg, Throwable t, int httpErrorCode, String oAuth2ErrorCode) {
        super(msg, t);
        this.httpErrorCode = httpErrorCode;
        this.oAuth2ErrorCode = oAuth2ErrorCode;
    }

    @Override
    public String getOAuth2ErrorCode() {
        return oAuth2ErrorCode;
    }

    @Override
    public int getHttpErrorCode() {
        return httpErrorCode;
    }
}
